Test or print testee results to compare to an expected value
Note: the "comparison" can be done by printing and checking visually. Later you can add more sophistication to your test (i.e. let the computer do comparisons for you).
The "smoke test" is a great initial test. It answers this question -- do we have a forest fire? In coding terms -- does our software "blow up" while doing essential (core) operations? Or, does our software "not even start up"?
It's an important test because the worst thing is to deliver to another team (or grader) software that is on fire (doesn't work at all). The other team will not be able to use it -- and their work will likely be "blocked" if they depend on it. And, the grader, if they can't even start the software, will not be able to give us many points, if even any at all.
Basically smoke tests exercise essential/core parts of the software code.
Smoke Test Purpose
The purpose is to test the essentials
Run the software
Construct objects
Send simple messages to the objects
Example 1
Believe it or not, this little smoke test can find a number of blocker bugs: run problems, construction problems, message problems.
let array = new DynamicArray();
println(array.size());
Example 2
Recognizing that "add" is a essential core method, we run a smoke test that sends "add".
let array = new DynamicArray();
array.add('asha@hello.com');
println(array.size());
Graders and object will be using/testing our objects from "other" directories (and importing our files as needed) so we want to do similar. Otherwise, there is a good chance we'll miss bugs that they will hit (and these could be "blocker bugs").
If we put our test code in another directory (apart from our model/domain) then we will exercise/test required "imports" etc of our code.
By domain/model we mean our data structures (e.g. dynamic arrays, linked lists, trees, etc).
Testing with primitives (e.g. integers, strings, doubles) is an okay way to get started testing. But see "lessons learned" on testing with "proper objects".
class DynamicArrayTest {
test_get_usingStrings() {
let nm1 = 'Asha';
let nm2 = 'Kofi';
let dynamic = DynamicArray.newEmpty();
dynamic.add(nm1);
dynamic.add(nm2);
var result, expected;
result = dynamic.get(0);
expected = nm1;
this.show(result.toString());
this.show(expected.toString());
result = dynamic.get(1);
expected = nm2;
this.show(result.toString());
this.show(expected.toString());
//we could also test "first" and "last" the same way
}
//...
}